//
//  DutyOvertimeViewController.m
//  MobileOffice
//
//  Created by jjkj on 16/11/10.
//  Copyright © 2016年 liaoningjujin. All rights reserved.
//

#import "DutyOvertimeViewController.h"
#import "SelectOvertimePersonViewController.h"
#import "DepartPersonListView.h"
#import "DutyMapViewController.h"
#import "DutyOvertimeModel.h"

#define getDepartPersonList @"getDepartPersonList"
#define postApplyForOvertimeInfo @"postApplyForOvertimeInfo"//加班申请提交
#define getOverTimeInfo @"getOvertimeInfo"//加班信息申请

@interface DutyOvertimeViewController ()
@property (nonatomic,strong) UILabel *personLabel;//加班人员label
@property (nonatomic,strong) UILabel *addressLabel;//加班地点label
@property (nonatomic,strong) UILabel *addressTitleLabel;//加班地点TitleLabel
@property (nonatomic,strong) NSString *cityName;//城市
@property (nonatomic,strong) NSString *placeX;//纬度
@property (nonatomic,strong) NSString *placeY;//经度
@property (nonatomic,strong) DepartPersonListModel *personListModel;
@property (nonatomic,strong) DutyOvertimeModel *overtimeModel;
@end

@implementation DutyOvertimeViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    // Do any additional setup after loading the view.
}

#pragma mark -初始化数据
- (void)dataInit{
    self.businessCode=@"JB0011";
    self.mustSelectArr=[NSMutableArray new];
    self.addWorkPersonArr=[NSMutableArray new];
    _titleArr=@[@"申请人员 :",@"开始时间 :",@"结束时间 :",@"加班人员 :",@"加班地点 :",@"加班事由 :"];
    _messageArr=[NSMutableArray arrayWithArray:@[[LZXHelper getUserName],self.beginStr?self.beginStr:@"点击选择",self.endStr?self.endStr:@"点击选择",[LZXHelper getUserName],@"点击进入地图",@""]];
    if (self.beginStr&&self.endStr) {
        [self getVacateDaysOnlyRequest];
    }

}

#pragma mark — creatView
- (void)creatView{
    UIView *userInfoView=[[UIView alloc]initWithFrame:CGRectMake(0, 0, IPHONE_WIDTH, 40)];
    userInfoView.backgroundColor=COLOR_SKYBLUE;
    [self.view addSubview:userInfoView];
    
    self.vacationTime=[MyControl creatLabelWithFrame:CGRectMake((IPHONE_WIDTH-220)/2, 0, 220, 40) text:@""];
    self.vacationTime.textAlignment=NSTextAlignmentCenter;
    [userInfoView addSubview:self.vacationTime];
    
    //假期时长提示
    self.vacationTimeButton=[MyControl creatButtonWithFrame:CGRectMake(IPHONE_WIDTH-58, 7.5, 25, 25) target:self sel:@selector(vacationTimeButtonClick) tag:102 image:@"k_tishi@2x" title:nil];
    self.vacationTimeButton.hidden=YES;
    [userInfoView addSubview:self.vacationTimeButton];
    
    //制度按钮
    self.systemButton=[MyControl creatButtonWithFrame:CGRectMake(IPHONE_WIDTH-58, 0, 50, 40) target:self sel:@selector(systemButtonClick) tag:101 image:nil title:@"制度"];
    self.systemButton.hidden=YES;
    [userInfoView addSubview:self.systemButton];
    
    //创建列表
    _tableView=[[UITableView alloc]initWithFrame:CGRectMake(0, 40, IPHONE_WIDTH, IPHONE_HEIGHT-40-64) style:UITableViewStylePlain];
    //_myTableView.backgroundColor=[UIColor redColor];
    _tableView.delegate=self;
    _tableView.dataSource=self;
    _tableView.tag=110;
    _tableView.separatorStyle=UITableViewCellSeparatorStyleNone;
    _tableView.showsVerticalScrollIndicator=NO;
    _tableView.showsHorizontalScrollIndicator=NO;
    _tableView.bounces=NO;
    //[self addTableViewUpdateRefresh:_tableView BindingIdentity:@""];
    //    [self addTableViewLoadMoreData:_tableView BindingIdentity:@""];
    [self.view addSubview:_tableView];
    [self addTableViewFootView];
    
    //    DatePickerView *date=[[DatePickerView alloc]initWithFrame:CGRectMake(0, 0, IPHONE_WIDTH, IPHONE_HEIGHT)];
    //    [[[UIApplication sharedApplication].delegate window] addSubview:date];
}

- (void)addTableViewFootView{
    //添加提交button
    UIView *footView=[[UIView alloc]initWithFrame:CGRectMake(0, 0, IPHONE_WIDTH, 80)];
    footView.backgroundColor=[UIColor clearColor];
    
    NSArray *title=@[@"确定"];
    CGFloat buttonWidth=(IPHONE_WIDTH-(title.count+1)*10)/title.count;
    for (int i=0; i<title.count; i++) {
        UIButton *submitButton=[MyControl creatButtonWithFrame:CGRectMake(10*(i+1)+buttonWidth*i,20, buttonWidth, 40) target:self sel:@selector(submitClick:) tag:120+i image:nil title:title[i]];
        submitButton.layer.masksToBounds=YES;
        submitButton.layer.cornerRadius=5;
        [submitButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        if (i==0) {
            submitButton.backgroundColor=COLOR_MIDBLUE;
        }else{
            submitButton.backgroundColor=[UIColor orangeColor];
        }
        [footView addSubview:submitButton];
    }
    _tableView.tableFooterView=footView;
}

#pragma mark -textViewDelegate

- (void)textViewDidBeginEditing:(UITextView *)textView{
    [self setLabelBorderColorWithLabel:self.reasonTitleLabel color:[UIColor clearColor]];
    NSIndexPath* path = [NSIndexPath indexPathForRow:5 inSection:0];
    [self performSelector:@selector(scrollToCell:) withObject:path afterDelay:0];
}

-(void) scrollToCell:(NSIndexPath*) path {
    [_tableView scrollToRowAtIndexPath:path atScrollPosition:UITableViewScrollPositionTop animated:YES];
}

#pragma mark - TableViewDelagate

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return _titleArr.count;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.row==0||indexPath.row==3) {
        NSString *cellID=@"DutyBasicTableViewCell";
        DutyBasicTableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:cellID];
        if (!cell) {
            cell=[[DutyBasicTableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellID];
            cell.selectionStyle=UITableViewCellSelectionStyleNone;
            if (indexPath.row==3) {
                cell.messageLabel.numberOfLines=0;
                cell.messageLabel.y=0;
                cell.messageLabel.height=50;
                _personLabel=cell.messageLabel;
            }
        }
        cell.myTitleLabel.text=_titleArr[indexPath.row];
        cell.messageLabel.text=_messageArr[indexPath.row];
        return cell;
    }else if (indexPath.row==1||indexPath.row==2||indexPath.row==4){
        NSString *cellID=@"DutyBasicTableViewCell";
        DutyBasicTableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:cellID];
        if (!cell) {
            cell=[[DutyBasicTableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellID];
            cell.selectionStyle=UITableViewCellSelectionStyleNone;
            if (indexPath.row==1) {
                [cell.signButton addTarget:self action:@selector(signButtonClick:) forControlEvents:UIControlEventTouchUpInside];
            }
        }
        cell.myTitleLabel.text=_titleArr[indexPath.row];
        cell.messageLabel.text=_messageArr[indexPath.row];
        
        if (indexPath.row==1) {
            self.beginSignButton=cell.signButton;
            self.beginTitleLabel=cell.myTitleLabel;
        }else if (indexPath.row==2){
            self.endSignButton=cell.signButton;
            self.endTitleLabel=cell.myTitleLabel;
        }
        //开始时间  结束时间
        if (indexPath.row==1||indexPath.row==2) {
            cell.arrowImageView.hidden=NO;
            if ([cell.messageLabel.text isEqualToString:@"点击选择"]) {
                cell.messageLabel.textColor=[UIColor lightGrayColor];
            }else{
                cell.messageLabel.textColor=[UIColor blackColor];
            }
            //地图选择
        }else{
            cell.arrowImageView.hidden=YES;
            if ([cell.messageLabel.text isEqualToString:@"点击进入地图"]) {
                cell.messageLabel.textColor=[UIColor lightGrayColor];
            }else{
                cell.messageLabel.textColor=[UIColor blackColor];
            }
            _addressTitleLabel=cell.myTitleLabel;
            _addressLabel=cell.messageLabel;
            cell.signButton.hidden=NO;
            [cell.signButton setBackgroundImage:[UIImage imageNamed:@"k_dingwei@2x"] forState:UIControlStateNormal];
        }
        return cell;
    }else{
        NSString *cellID=@"ReasonTextTableViewCell";
        ReasonTextTableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:cellID];
        if (!cell) {
            cell=[[ReasonTextTableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellID title:@" 请填/选请假事由 : " noticeStr:nil];
            cell.selectionStyle=UITableViewCellSelectionStyleNone;
        }
        self.reasonTextView=cell.reasonTextView;
        self.reasonTextView.delegate=self;
        self.reasonTitleLabel=cell.myTitleLabel;
        return cell;
    }
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [self.reasonTextView resignFirstResponder];
    if (indexPath.row==1||indexPath.row==2){
        NSString *dateStr=nil;
        if (indexPath.row==1) {
            if (self.beginStr) {
                dateStr=self.beginStr;
            }else if (self.endStr){
                dateStr=self.endStr;
            }
        }
        if (indexPath.row==2) {
            if (self.endStr) {
                dateStr=self.endStr;
            }else if (self.beginStr){
                dateStr=self.beginStr;
            }
        }
        DatePickerView *datePickerView=[[DatePickerView alloc]initWithFrame:CGRectMake(0, 0, IPHONE_WIDTH, IPHONE_HEIGHT)nowDateStr:dateStr];
        __weak NSMutableArray *myMessageArr=_messageArr;
        __weak UITableView *myTableView=_tableView;
        __weak DutyParentsViewController *mySelf=self;
        datePickerView.sureBlock=^(NSString *timeStr){
            if (indexPath.row==1) {
                //如果是选择开始时间
                //先判断有没有结束时间,如果有要进行比对
                if (mySelf.endStr) {
                    if (![mySelf compareOneTime:timeStr withAnotherTime:mySelf.endStr]) {
                        [LZXHelper postMessageWithText:@"加班结束时间应该在请假开始时间之后!" View:mySelf.view];
                    }
                    [mySelf getVacateDaysOnlyRequest];
                }
                //比现在的时间晚
                mySelf.beginStr=[timeStr copy];
                
                [mySelf setLabelBorderColorWithLabel:mySelf.beginTitleLabel color:[UIColor clearColor]];
                [myMessageArr replaceObjectAtIndex:indexPath.row withObject:timeStr];
                [myTableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
                [mySelf getTimeControlRequestWithBeginTime:[timeStr copy]endTime:nil type:@"Begin"];
            }else{
                //点击结束时间
                mySelf.endStr=[timeStr copy];
                [mySelf setLabelBorderColorWithLabel:mySelf.endTitleLabel color:[UIColor clearColor]];
                [myMessageArr replaceObjectAtIndex:indexPath.row withObject:timeStr];
                [myTableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
                [mySelf getVacateDaysOnlyRequest];
                [mySelf getTimeControlRequestWithBeginTime:mySelf.beginStr endTime:[timeStr copy] type:@"End"];
            }
        };
        [[[UIApplication sharedApplication].delegate window] addSubview:datePickerView];
        //加班人员选择
    }else if (indexPath.row==3){
        if (_personListModel) {
            [self postSelectPersonController:_personListModel];
        }else{
            [self getDepartPersonListRequest];
        }
        
    }else if (indexPath.row==4){
        DutyMapViewController *map=[DutyMapViewController new];
        __weak DutyOvertimeViewController *mySelf=self;
        if (![self.addressLabel.text isEqualToString:@"点击进入地图"]) {
            map.addressStr=self.addressLabel.text;
            map.cityName=_cityName;
        }
        map.myBlock=^(NSString *addressStr,NSString *cityName,NSString *placeX,NSString *placeY,NSString *nowAddressStr){
            [mySelf setLabelBorderColorWithLabel:mySelf.addressTitleLabel color:[UIColor clearColor]];
            mySelf.cityName=[cityName copy];
            mySelf.addressLabel.text=[addressStr copy];
            mySelf.addressLabel.textColor=[UIColor blackColor];
            mySelf.placeX=[placeX copy];
            mySelf.placeY=[placeY copy];
        };
        [self.navigationController pushViewController:map animated:YES];
    }
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.row==5){
        return 100;
    }
    return 50;
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 0;
}

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return 0;
}


#pragma mark -进入人员选择页面
- (void)postSelectPersonController:(DepartPersonListModel *)model{
    SelectOvertimePersonViewController *overtime=[SelectOvertimePersonViewController new];
    overtime.personListModel=model;
    __weak DutyOvertimeViewController *mySelf=self;
    overtime.myBlock=^(){
        NSString *personMsg=_messageArr[3];
        //拼接字符串
        for (DepartPersonListModel *model in self.personListModel.dataArr) {
            if (model.isSelect) {
                personMsg=[personMsg stringByAppendingString:[NSString stringWithFormat:@",%@",model.empName]];
            }
        }
        mySelf.personLabel.text=personMsg;
    };
    [self.navigationController pushViewController:overtime animated:YES];
}

#pragma mark -获取人员列表请求

- (void)getDepartPersonListRequest{
    NSDictionary *dict=@{
                         @"departName":[LZXHelper getUserDepartName]?[LZXHelper getUserDepartName]:@"",
                         };
    
    //   字典转json
    NSData* jsonData = [NSJSONSerialization dataWithJSONObject:dict options:NSJSONWritingPrettyPrinted error:nil];
    NSString* str = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
    //拼接soap字符串
    NSString* soap = [NSString stringWithFormat:@"<sessionId>%@</sessionId>\n<content>%@</content>",[LZXHelper getSessionID],str];
    [LZXHelper postLoadViewWithText:HUD_PLEASEWAIT View:self.view];
    // __weak AddressBookViewController *mySelf=self;
    [HttpRequest SOAPData:[LZXHelper getServerURL] SoapMthod:getDepartPersonList soapBody:soap success:^(id responseObject) {
        [LZXHelper hideLoadViewWithView:self.view];
        
        //解析数据
        _personListModel=[[DepartPersonListModel alloc]initWithResponse:responseObject];
        if ([_personListModel.code isEqualToString:@"200"]) {
            [self postSelectPersonController:_personListModel];

        }else if([_personListModel.code isEqualToString:@"220"]){
            [LZXHelper postMessageWithText:_personListModel.msg View:self.view];
        }
    } failure:^(NSError *error) {
        [LZXHelper hideLoadViewWithView:self.view];
    }];
}


#pragma mark -获取提交时的提示文字

- (void)submitApplyRequestWithState:(NSString *)state{
    //如果有必选项没填则需提示和标记出来
    if (!self.beginStr) {
        [LZXHelper postMessageWithText:@"加班开始时间不能为空!" View:self.view];
        [self setLabelBorderColorWithLabel:self.beginTitleLabel color:[UIColor redColor]];
        return;
    }else{
        [self setLabelBorderColorWithLabel:self.beginTitleLabel color:[UIColor clearColor]];
    }
    
    if (!self.endStr) {
        [LZXHelper postMessageWithText:@"加班结束时间不能为空!" View:self.view];
        [self setLabelBorderColorWithLabel:self.endTitleLabel color:[UIColor redColor]];
        return;
    }else{
        [self setLabelBorderColorWithLabel:self.endTitleLabel color:[UIColor clearColor]];
    }
    
    //    if (![self compareOneTime:self.beginStr withAnotherTime:self.endStr]) {
    //        [LZXHelper postMessageWithText:@"请假结束时间应该在请假开始时间之后!" View:self.view];
    //        //[self setLabelBorderColorWithLabel:_beginTitleLabel with:[UIColor redColor]];
    //        return;
    //    }
    //    else{
    //        [self setLabelBorderColorWithLabel:_beginTitleLabel with:[UIColor redColor]];
    //    }
    if ([_beginTimeModel.isCanCommit isEqualToString:@"0"]||_beginTimeModel==nil) {
        [LZXHelper postMessageWithText:_beginTimeModel.myMessage View:self.view];
        [self setLabelBorderColorWithLabel:self.beginTitleLabel color:[UIColor redColor]];
        return;
    }else{
        [self setLabelBorderColorWithLabel:self.beginTitleLabel color:[UIColor clearColor]];
    }
    
    if ([self.endTimeModel.isCanCommit isEqualToString:@"0"]||self.endTimeModel==nil) {
        [LZXHelper postMessageWithText:self.endTimeModel.myMessage View:self.view];
        [self setLabelBorderColorWithLabel:self.endTitleLabel color:[UIColor redColor]];
        return;
    }else{
        [self setLabelBorderColorWithLabel:self.endTitleLabel color:[UIColor clearColor]];
    }
    
    if ([self.addressLabel.text isEqualToString:@"点击进入地图"]) {
        [LZXHelper postMessageWithText:@"加班地点不能为空!" View:self.view];
        [self setLabelBorderColorWithLabel:self.addressTitleLabel color:[UIColor redColor]];
        return;
    }else{
        [self setLabelBorderColorWithLabel:self.addressTitleLabel color:[UIColor clearColor]];
    }
    
    if (self.reasonTextView.text.length==0) {
        [LZXHelper postMessageWithText:@"加班事由不能为空!" View:self.view];
        [self setLabelBorderColorWithLabel:self.reasonTitleLabel color:[UIColor redColor]];
        return;
    }else{
        [self setLabelBorderColorWithLabel:self.reasonTitleLabel color:[UIColor clearColor]];
    }
    
    if ([self.holidayCount isEqualToString:@"0"]||[self.holidayCount isEqualToString:@"0.0"]||[self.holidayCount isEqualToString:@"0.00"]||self.holidayCount==nil) {
        [LZXHelper postMessageWithText:[NSString stringWithFormat:@"%@时长不能为0!",self.navaTitle] View:self.view];
        [self setLabelBorderColorWithLabel:self.holidaysTitleLabel color:[UIColor redColor]];
        return;
    }else{
        [self setLabelBorderColorWithLabel:self.holidaysTitleLabel color:[UIColor clearColor]];
    }
    
    NSDictionary *dict=@{
                         @"BusinessCode":self.businessCode?self.businessCode:@"",
                         @"BeginTime":self.beginStr?self.beginStr:@"",
                         @"EndTime":self.endStr?self.endStr:@"",
                         @"LeaveTypePK":@"0011",
                         @"vacateBillId":self.vacateBillId?self.vacateBillId:@""
                         };
    
    //   字典转json
    NSData* jsonData = [NSJSONSerialization dataWithJSONObject:dict options:NSJSONWritingPrettyPrinted error:nil];
    NSString* str = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
    //拼接soap字符串
    NSString* soap = [NSString stringWithFormat:@"<sessionId>%@</sessionId>\n<content>%@</content>",[LZXHelper getSessionID],str];
    //[LZXHelper postLoadViewWithText:HUD_PLEASEWAIT View:self.view];
    // __weak AddressBookViewController *mySelf=self;
    [HttpRequest SOAPData:[LZXHelper getServerURL] SoapMthod:IsOverLaped soapBody:soap success:^(id responseObject) {
        //[LZXHelper hideLoadViewWithView:self.view];
        
        //解析数据
        BasicModel *model=[[BasicModel alloc]initWithResponse:responseObject];
        __weak DutyOvertimeViewController *mySelf=self;
        if ([model.code isEqualToString:@"200"]) {
            NSDictionary *dict=responseObject[@"retContent"];
            if ([dict[@"IsOverLap"] isEqualToString:@"0"]) {
                [LZXHelper postAlertViewControllerWithTitle:dict[@"strDesc"] message:nil cancelButtonTitle:@"取消" otherButtonTitle:@"确定" cancelEvent:^{
                    
                } otherEvent:^{
                    [mySelf postSickVacateInfoRequest];
                } viewController:mySelf];
            }else{
                DateConflictView *date=[[DateConflictView alloc]initWithFrame:CGRectMake(0, 0, IPHONE_WIDTH, IPHONE_HEIGHT) message:dict[@"strDesc"]];
                //确定回调函数
                date.promptTimeBlock=^(NSInteger selectNum){
                    mySelf.optionType=[NSString stringWithFormat:@"%ld",selectNum-1];
                    [mySelf postSickVacateInfoRequestWith:state];
                };
                //取消回调函数
                date.promptTimeCancelBlock=^(){
                    //_promptTimeView=nil;
                };
                [[[UIApplication sharedApplication].delegate window] addSubview:date];
            }
            
        }else if([model.code isEqualToString:@"220"]){
            [LZXHelper postMessageWithText:model.msg View:self.view];
        }
    } failure:^(NSError *error) {
        //[LZXHelper hideLoadViewWithView:self.view];
    }];
    
}

#pragma mark -申请提交
- (void)postSickVacateInfoRequest{
    NSDateFormatter *formatter=[[NSDateFormatter alloc]init];
    [formatter setDateFormat:@"yyyy-MM-dd HH:mm"];
    NSString *timeStr=[formatter stringFromDate:[NSDate date]];
    
    NSString *empId=[NSString stringWithFormat:@"|%@|",[LZXHelper getSessionID]];
    for (DepartPersonListModel *model in _personListModel.dataArr) {
        empId=[empId stringByAppendingString:[NSString stringWithFormat:@"%@|",model.personId]];
    }
    
    NSDictionary *dict=@{
                         @"applyTime":timeStr?timeStr:@"",
                         @"empIds":empId?empId:@"",
                         @"endTime":self.endStr?self.endStr:@"",
                         @"startTime":self.beginStr?self.beginStr:@"",
                         @"id":self.vacateBillId?self.vacateBillId:@"",
                         @"infoId":self.infoId?self.infoId:@"",
                         @"obAddress":self.addressLabel.text?self.addressLabel.text:@"",
                         @"optionType":self.optionType?self.optionType:@"",
                         @"rules":@"",
                         @"sendEmpId":@"",
                         @"serviceTime":self.serviceTime?self.serviceTime:timeStr,
                         @"overtimeReasons":self.reasonTextView.text,
                         @"placeX":self.placeX?self.placeX:@"",
                         @"placeY":self.placeY?self.placeY:@"",
                         };
    
    //   字典转json
    NSData* jsonData = [NSJSONSerialization dataWithJSONObject:dict options:NSJSONWritingPrettyPrinted error:nil];
    NSString* str = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
    //拼接soap字符串
    NSString* soap = [NSString stringWithFormat:@"<sessionId>%@</sessionId>\n<content>%@</content>",[LZXHelper getSessionID],str];
    [LZXHelper postLoadViewWithText:HUD_PLEASEWAIT View:self.view];
    // __weak AddressBookViewController *mySelf=self;
    [HttpRequest SOAPData:[LZXHelper getServerURL] SoapMthod:postApplyForOvertimeInfo soapBody:soap success:^(id responseObject) {
        [LZXHelper hideLoadViewWithView:self.view];
        
        //解析数据
        BasicModel *model=[[BasicModel alloc]initWithResponse:responseObject];
        if ([model.code isEqualToString:@"200"]) {
            [LZXHelper postMessageWithText:model.msg View:[[UIApplication sharedApplication].delegate window]];
            if (self.vacateBillId) {
                for (UIViewController *controller in self.navigationController.viewControllers) {
                    if ([controller isKindOfClass:[MyJobListViewController class]]) {
                        [self.navigationController popToViewController:controller animated:YES];
                    }
                }
            }else{
                [self.navigationController popViewControllerAnimated:YES];
            }
        }else if([model.code isEqualToString:@"220"]){
            [LZXHelper postMessageWithText:model.msg View:[[UIApplication sharedApplication].delegate window]];
        }
        } failure:^(NSError *error) {
        //[LZXHelper hideLoadViewWithView:self.view];
    }];
}


#pragma mark -已核销查看页面加班信息
- (void)getVacateInfoRequestWithVacateBillId:(NSString *)vacateBillId{
    
    NSDictionary *dict=@{
                         @"vacateBillId":vacateBillId?vacateBillId:@"",
                         @"businessCode":self.businessCode?self.businessCode:@"",
                         };
    
    //   字典转json
    NSData* jsonData = [NSJSONSerialization dataWithJSONObject:dict options:NSJSONWritingPrettyPrinted error:nil];
    NSString* str = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
    //拼接soap字符串
    NSString* soap = [NSString stringWithFormat:@"<sessionId>%@</sessionId>\n<content>%@</content>",[LZXHelper getSessionID],str];
    // __weak AddressBookViewController *mySelf=self;
    //[LZXHelper postLoadViewWithText:HUD_PLEASEWAIT View:self.view];
    [HttpRequest SOAPData:[LZXHelper getServerURL] SoapMthod:getOverTimeInfo soapBody:soap success:^(id responseObject) {
        //[LZXHelper hideLoadViewWithView:self.view];
        
        //解析数据
        BasicModel *model=[[BasicModel alloc]initWithResponse:responseObject];
        if ([model.code isEqualToString:@"200"]) {
            [self getVacateInfoRequestSuccess:responseObject];
        }else if([model.code isEqualToString:@"220"]){
            [LZXHelper postMessageWithText:model.msg View:self.view];
        }
    } failure:^(NSError *error) {
        //[LZXHelper hideLoadViewWithView:self.view];
    }];
}

#pragma mark -页面信息请求成功
- (void)getVacateInfoRequestSuccess:(id)responseObject{
//    //解析数据
    self.overtimeModel=[[DutyOvertimeModel alloc]initWithResponse:responseObject];
    self.beginStr=self.overtimeModel.startTime;
    self.endStr=self.overtimeModel.endTime;
    self.placeX=self.overtimeModel.placeX;
    self.placeY=self.overtimeModel.placeY;
    self.taskId=self.infoModel.TaskID;
    self.reasonTextView.text=self.overtimeModel.overtimeReasons;
    self.reasonTextView.textColor=[UIColor blackColor];
    //替换数据
    _messageArr=[NSMutableArray arrayWithArray:@[[LZXHelper getUserName],self.beginStr?self.beginStr:@"点击选择",self.endStr?self.endStr:@"点击选择",[LZXHelper getUserName],self.overtimeModel.obAddress?self.overtimeModel.obAddress:@"点击进入地图",self.overtimeModel.overtimeReasons?self.overtimeModel.overtimeReasons:@""]];
    [self getVacateDaysOnlyRequest];
    [self getTimeControlRequestWithBeginTime:self.beginStr endTime:nil type:@"Begin"];
    [self getTimeControlRequestWithBeginTime:self.beginStr endTime:self.endStr type:@"End"];
    [_tableView reloadData];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
